package JavaSEAdvance.day07_Exception;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;

/**
 * @author Xiao
 * @date 2021/7/24
 */
public class D702_ThrowDemo02 {
    public static void main(String[] args) throws ParseException {
        parseStr("2001/01/01");
    }

    public static void parseStr(String str) throws ParseException {
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            Date date = sdf.parse(str);
            System.out.println(date);
        } catch (ParseException e) {
            e.printStackTrace();
            System.out.println("您输入的日期格式不正确");
        }
    }
}
